package com.dic.activity;

import com.dic.R;

import android.app.Activity;
import android.app.TabActivity;
import android.os.Bundle;
import android.view.GestureDetector;
import android.view.MotionEvent;
import android.view.Window;
import android.view.GestureDetector.OnGestureListener;
import android.widget.TabHost;

public class AboutActivity extends Activity implements OnGestureListener {

	private GestureDetector detector;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.about_view);

		detector = new GestureDetector(this);
	}

	@Override
	public boolean dispatchTouchEvent(MotionEvent ev) {

		detector.onTouchEvent(ev);
		return super.dispatchTouchEvent(ev);
	}

	@Override
	public boolean onDown(MotionEvent e) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
		// TODO Auto-generated method stub

		TabHost mTabHost = (((TabActivity) getParent()).getTabHost());
		int tabId = mTabHost.getCurrentTab();

		if (Math.abs(e1.getY() - e2.getY()) > 100) {
			// Toast.makeText(context, "WRONG!!!!", Toast.LENGTH_LONG).show();
			return false;
		}

		if ((e1.getX() - e2.getX()) > 50 && Math.abs(velocityX) > 100) {
			// Toast.makeText(context, "To Right!!!!", Toast.LENGTH_LONG).show();
			if (tabId == 0 || tabId == 1) {
				tabId++;
			}

		} else if ((e2.getX() - e1.getX()) > 50 && Math.abs(velocityX) > 100) {
			// Toast.makeText(context, "To Left!!!!", Toast.LENGTH_LONG).show();
			if (tabId == 2 || tabId == 1) {
				tabId--;
			}
		}
		mTabHost.setCurrentTab(tabId);

		return false;
	}

	@Override
	public void onLongPress(MotionEvent e) {
		// TODO Auto-generated method stub

	}

	@Override
	public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public void onShowPress(MotionEvent e) {
		// TODO Auto-generated method stub

	}

	@Override
	public boolean onSingleTapUp(MotionEvent e) {
		// TODO Auto-generated method stub
		return false;
	}
}
